package com.hgf.helper.mybatisplusdemo.db.entity;

import com.baomidou.mybatisplus.annotation.FieldStrategy;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
import com.hgf.helper.mybatisplus.BaseEntity;
import com.hgf.helper.mybatisplus.annotation.Association;
import com.hgf.helper.mybatisplus.annotation.MpJoinColumn;
import lombok.Getter;
import lombok.Setter;

import java.time.LocalDateTime;
import java.util.List;

/**
 * 学生信息
 */
@Setter
@Getter
@TableName(value = "student", autoResultMap = true)
public class Student extends BaseEntity {

    /**
     * 名字
     */
    @TableField
    String name;

    /**
     * 生日
     */
    @TableField
    LocalDateTime birthday;

    /**
     * 性别 1-男 2-女
     */
    @TableField
    int sex;

    /**
     * 编号
     */
    @TableField("no")
    String no;

    /**
     * 分数信息
     */
    @Association(aliasPrefix = "sc_")
    @TableField(select = false,
            typeHandler = JacksonTypeHandler.class,
            insertStrategy = FieldStrategy.NEVER,
            whereStrategy = FieldStrategy.NEVER)
    @MpJoinColumn(mainFieldName = "no",refFieldName = "stuNo")
    ScoreInfo score;


    @Association(aliasPrefix = "ri_")
    @TableField(select = false,
            typeHandler = JacksonTypeHandler.class,
            insertStrategy = FieldStrategy.NEVER,
            whereStrategy = FieldStrategy.NEVER)
    @MpJoinColumn(mainFieldName = "no",refFieldName = "stuNo")
    List<RewardInfo> rewardInfos;


}
